<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <title>${sessionScope.LOGIN_USER.nickname}的主页</title>
    <meta name="keywords" content="安达世纪,蓝色科技"/>
    <meta name="description" content="安达世纪蓝色科技"/>
    <meta name="author" content="DeathGhost"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--产品logo-->
    <link rel="icon" href="${pageContext.request.contextPath}/images/icon/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css"/>
    <!--jQuery v3.2.1-->
    <script src="${pageContext.request.contextPath}/javascript/jquery.js"></script>
    <!--jquery.easyui v1.3.4-->
    <script src="${pageContext.request.contextPath}/javascript/jquery.easyui.min.js"></script>
    <!--滚动插件-->
    <script src="${pageContext.request.contextPath}/javascript/plug-ins/customScrollbar.min.js"></script>
    <!--统计插件-->
    <script src="${pageContext.request.contextPath}/javascript/plug-ins/echarts.min.js"></script>
    <!--弹框插件-->
    <script src="${pageContext.request.contextPath}/javascript/plug-ins/layerUi/layer.js"></script>
    <!--HTML编辑器插件-->
    <script src="${pageContext.request.contextPath}/editor/ueditor.config.js"></script>
    <!--HTML编辑器插件-->
    <script src="${pageContext.request.contextPath}/editor/ueditor.all.js"></script>
    <!--分页插件-->
    <script src="${pageContext.request.contextPath}/javascript/plug-ins/pagination.js"></script>
    <!--整个模板样式控制文件-->
    <script src="${pageContext.request.contextPath}/javascript/public.js"></script>
    <script>
        var http = "${pageContext.request.contextPath}";
        /*
         分页
         * */
        $(".pagination").createPage({
            pageCount: 11,
            current: 1,
            backFn: function (p) {
                console.log(p);
            }
        });

    </script>
    <style>

    </style>
</head>
<body>
<div class="main-wrap">
    <div class="side-nav">
        <div class="side-logo">
            <div class="logo">
				<span class="logo-ico">
					<i class="i-l-1"></i>
					<i class="i-l-2"></i>
					<i class="i-l-3"></i>
				</span>
                <strong>保理软件</strong>
            </div>
        </div>

        <nav class="side-menu content mCustomScrollbar" data-mcs-theme="minimal-dark">
            <h2>
                <a href="javascript:void(0);" class="InitialPage"
                   onclick="addTab('待办事项','${pageContext.request.contextPath}/homepage')"><i class="icon-list-alt"></i>待办事项</a>
            </h2>
            <ul>
                <c:forEach items="${sessionScope.menuinfo}" var="one">
                    <li>
                        <dl>
                            <dt>
                                <i class="${one.icon}"></i>${one.sysResourceName}<i class="icon-angle-right"></i>
                            </dt>
                            <c:forEach items="${one.childs}" var="two">
                                <dd>
                                    <a href="javascript:void(0);" target="sysmain"
                                       onclick="addTab('${two.sysResourceName}','${pageContext.request.contextPath}${two.url}')">${two.sysResourceName}</a>
                                </dd>
                            </c:forEach>
                        </dl>
                    </li>
                </c:forEach>
            </ul>
        </nav>
        <footer class="side-footer">© jiudingkeji 版权所有</footer>
    </div>
    <div class="content-wrap">
        <!--header头部菜单-->
        <header class="top-hd">
            <div class="hd-lt">
                <a class="icon-reorder" title="显示隐藏功能菜单"></a>
            </div>
            <div class="hd-rt">
                <ul>
                    <li>
                        <a><i class="icon-user"></i>保理软件:<em>${sessionScope.LOGIN_USER.nickname}</em></a>
                    </li>
                    <li>
                        <a href="javascript:void(0)" id="logout" onclick="logout()"><i class="icon-signout"></i>安全退出</a>
                    </li>
                </ul>
            </div>
        </header>
        <!--软件主体内容-->
        <main class="main-cont1 content">
            <!--开始::内容-->
            <div id="tt" class="easyui-tabs main-cont">
                <div title="待办事项" class="icon-mini-refresh">
                    <iframe scrolling="auto" id="mywork" frameborder="0" style="width:100%;height:100%;"></iframe>
                </div>

            </div>
            <!--开始::结束-->
        </main>
        <!--底部版权申明-->
        <footer class="btm-ft">
            <p class="clear">
                <span class="fl">©Copyright 2017 <a href="#" title="DeathGhost" target="_blank">保理软件</a></span>
                <span class="fr text-info">
					<em class="uppercase">
						<i class="icon-user"></i>
						jiudingkeji
					</em> |
					<em class="uppercase"><i class="icon-home"></i>
						<a href="javascript:void(0);" target="_blank">官网</a>
					</em>
				</span>
            </p>
        </footer>
    </div>
</div>
<div id="mm" class="easyui-menu" style="width:120px;">
    <div id="mm-tabclosrefresh" data-options="name:6">刷新</div>
    <div id="mm-tabclose" data-options="name:1">关闭</div>
    <div id="mm-tabcloseall" data-options="name:2">全部关闭</div>
    <div id="mm-tabcloseother" data-options="name:3">除此之外全部关闭</div>
    <div class="menu-sep"></div>
    <div id="mm-tabcloseright" data-options="name:4">当前页右侧全部关闭</div>
    <div id="mm-tabcloseleft" data-options="name:5">当前页左侧全部关闭</div>
</div>
<div id="indexmm" class="easyui-menu" style="width:120px;">
    <div onclick="tabclosrefresh('${pageContext.request.contextPath}/homepage')">刷新</div>
    <div class="menu-sep"></div>
    <div onclick="tabcloseright()">当前页右侧全部关闭</div>
    <div onclick="tabcloseright()">除此之外全部关闭</div>
</div>
<script>
    window.onresize = function () {
        loadiframe();
        sizeHasBeenChanged()
    }
    /*
     自定义工具栏
     * */
    $('body').on('contextmenu', 'li', function (e) {
        var thisText = $.trim($(this).find('.tabs-title').text());
        if (thisText == '待办事项') {
            $('#indexmm').menu('show', {
                left: e.pageX,
                top: e.pageY
            });
        } else {
            return false
        }
    });
    $(document).ready(function () {
        //监听右键事件，创建右键菜单
        $('#tt').tabs({
            onContextMenu: function (e, title, index) {
                e.preventDefault();
                if (index > 0) {
                    $('#mm').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    }).data("tabTitle", title);
                }
            }
        });
        //右键菜单click
        $("#mm").menu({
            onClick: function (item) {
                closeTab(this, item.name);
            }
        });
    });
    //删除Tabs
    function closeTab(menu, type) {
        console.log(type)
        var allTabs = $("#tt").tabs('tabs');
        var allTabtitle = [];
        $.each(allTabs, function (i, n) {
            var opt = $(n).panel('options');
            if (opt.closable)
                allTabtitle.push(opt.title);
        });
        var curTabTitle = $(menu).data("tabTitle");
        var curTabIndex = $("#tt").tabs("getTabIndex", $("#tt").tabs("getTab", curTabTitle));
        switch (type) {
            case 1:
                $("#tt").tabs("close", curTabIndex);
                return false;
                break;
            case 2:
                for (var i = 0; i < allTabtitle.length; i++) {
                    $('#tt').tabs('close', allTabtitle[i]);
                }
                break;
            case 3:
                for (var i = 0; i < allTabtitle.length; i++) {
                    if (curTabTitle != allTabtitle[i])
                        $('#tt').tabs('close', allTabtitle[i]);
                }
                $('#tt').tabs('select', curTabTitle);
                break;
            case 4:
                for (var i = curTabIndex; i < allTabtitle.length; i++) {
                    $('#tt').tabs('close', allTabtitle[i]);
                    console.log(allTabtitle[i])
                }
                $('#tt').tabs('select', curTabTitle);
                break;
            case 5:
                for (var i = 0; i < curTabIndex - 1; i++) {
                    $('#tt').tabs('close', allTabtitle[i]);
                }
                $('#tt').tabs('select', curTabTitle);
                break;
            case 6: //刷新
                var panel = $("#tt").tabs("getTab", curTabTitle).panel("refresh");
                loadiframe();
                break;
        }
    }
    /*
     当前页右侧全部关闭
     * */
    function tabcloseright() {
        var allTabs = $("#tt").tabs('tabs');
        var allTabtitle = [];
        $.each(allTabs, function (i, n) {
            var opt = $(n).panel('options');
            if (opt.closable)
                allTabtitle.push(opt.title);
        });
        var curTabIndex = $("#tt").tabs("getTabIndex", $("#tt").tabs("getTab", 20));
        for (var i = curTabIndex; i < allTabtitle.length; i++) {
            $('#tt').tabs('close', allTabtitle[i]);
        }
    }
    /*
     刷新
     * */
    function tabclosrefresh(url) {
        $('#mywork').attr('src', url)
    }

    function logout() {
        window.location.href = http + "/userlogout";
    }
    $(function () {
        tabclosrefresh("${pageContext.request.contextPath}/homepage");
    });
</script>
</body>
</html>
